package pl.edu.agh.anomalyids.launcher;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import pl.edu.agh.anomalyids.lerad.rule.Rule;
import pl.edu.agh.anomalyids.lerad.rule.RuleCreator;
import pl.edu.agh.anomalyids.lerad.rule.util.RuleWriter;
import pl.edu.agh.anomalyids.network.Packet;
import pl.edu.agh.anomalyids.network.util.PacketReader;

public class LearningLauncher {

	private static final Logger logger = LoggerFactory.getLogger(LearningLauncher.class);
	
	public static void main(String[] args) {
		if (args.length < 2) {
			System.out.println("Correct arguments: <input file path with packets> <output file path>");
			logger.error("Bad arguments.");
		}
		
		String packetsFilePath = args[0];
		List<Packet> packets = new PacketReader().read(packetsFilePath);
		
		List<Rule> rules = new RuleCreator(packets).generateRules().performCoverage().train().validate().getRules();
		
		String rulesFilePath = args[1];
		new RuleWriter(rules).write(rulesFilePath);
	}
}
